(display "\n========================================\n")
(define (accumulate op initial sequence)
    (if (null? sequence)
        initial
        (op (car sequence)
            (accumulate op initial (cdr sequence)))))

(define (count-leaves tree)
    (cond ((null? tree) 0)
          ((not (pair? tree)) 1)
          (else (+ (count-leaves (car tree))
                   (count-leaves (cdr tree))))))

(define x (cons (list 1 2) (list 3 4 (list 5 6))))
(display (count-leaves x))
(newline)

(define (count-leaves tree)
    (accumulate + 0 (map (lambda (sub-tree)
                                (if (not (pair? sub-tree))
                                    1
                                    (count-leaves sub-tree)))
                         tree)))

(display (count-leaves x))

(display "\n========================================\n")
